package com.imooc.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

/**
 * @program: foodie-dev
 * @description: hello控制器
 * @author: rZ
 * @create: 2020-02-21 17:06
 **/
@ApiIgnore
@RestController
public class HelloController {

    final static Logger logger= LoggerFactory.getLogger(HelloController.class);

    @GetMapping("hello")
    public Object Hello(){
        logger.info("info:hello!");
        return "hello world";
    }

    @GetMapping("/setSession")
    public Object setSession(HttpServletRequest request){
        HttpSession session = request.getSession();
        session.setAttribute("userInfo","new user");
        session.setMaxInactiveInterval(3600);
        session.getAttribute("userInfo");
        //session.removeAttribute("userInfo");
        return "ok";
    }
}
